#! /bin/sh
while true
do
# 删掉旧数据
rm /home/getip/index.html
# rm -f /home/getip/out.txt; 
rm -f tmp.txt 
rm -f /home/getip/ip-real.html
# 取得ip原数据
wget  http://ip.3322.net -O /home/getip/index.html
# 取出有用部分（即ip地址），存于tmp.txt
sed 's/^M//g' /home/getip/index.html > /home/getip/tmp.txt
sed -i 's/\"/\\\"/g' /home/getip/tmp.txt
# 删掉旧数据
# rm -f /home/getip/out.txt; 
# 创建新文件存新数据
# touch /home/getip/out.txt
# cat /home/getip/tmp.txt | xargs echo -n >> /home/getip/out.txt


cat /home/getip/html_header.html >> /home/getip/ip-real.html
# cat /home/getip/out.txt >> /home/getip/ip-real.html
# cat /home/getip/ip2.html >> /home/getip/ip-real.html

cat /home/getip/tmp.txt | xargs echo -n >> /home/getip/ip-real.html
cat /home/getip/html_footer.html >> /home/getip/ip-real.html

cp /home/getip//ip-real.html /var/www/html/ip.html

date >> /var/www/html/publicIPLog.html
echo " :<----public IP---->: " >> /var/www/html/publicIPLog.html
cat /home/getip/tmp.txt | xargs echo -n >> /var/www/html/publicIPLog.html
echo "<br>" >> /var/www/html/publicIPLog.html

    sleep 3600
done